home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 5
/
Aminet 5 - March 1995.iso
/
Aminet
/
misc
/
amag
/
AM9410_2.lha
/
Haufenweise
/
Programme
/
pooltest.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-07-15
|
1KB
|
53 lines
#include <clib/dos_protos.h>
#include <exec/memory.h>
#include <stdlib.h>
#include <stdio.h>
#define BLOCKGROESSE 100000 // 'großes' Stück
#define BLOCKTHRES 80000 // ab 80000 neues Stück
#define BLOCKMAXSIZE 120000 // maximale Testgröße
#define BLOCKANZAHL 20 // Allozierungen pro Pool
void *CreatePool13(ULONG Flags,ULONG RegionSize, ULONG NewSize);
void DeletePool13(APTR MyPool);
APTR AllocPooled13(void *MyPool,ULONG Size);
void FreePooled13(void *MyPool, APTR memaddr);
__far APTR memblocks[BLOCKANZAHL];
int main(int argc, char *agrv[])
{
APTR mypool;
register int i = 0, j = 0, k = 1000;
if (mypool = CreatePool13(MEMF_PUBLIC,BLOCKGROESSE,
BLOCKTHRES))
{ while (k-- > 0)
{ if ((k%100) == 0) // alle 100 Durchläufe
{ printf("k ist %ld, j ist %6ld\r",k,j);
fflush(stdout); // eine Ausgabe
}
for (i=0; i < BLOCKANZAHL;)
{
j = 20 + (rand() % BLOCKMAXSIZE);
if (!(memblocks[i++] = AllocPooled13(mypool,j)))
{ break; }
}
/* diese for-Schleife besser weglassen !! */
for (i=0; i < BLOCKANZAHL;i++)
{
if (memblocks[i])
{ FreePooled13(mypool,memblocks[i]);
memblocks[i] = 0L;
}
else
{ break; }
}
}
DeletePool13(mypool); // Pool freigeben
}
return 0L;
}